#include<bits/stdc++.h>
using namespace std;
int t,n,m,l,v,d[100010],c[100010],a[100010],b[100010],p[100010],maxa=-1e9,mina=1e9,ans,ans2;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--)
    {
        cin>>n>>m>>l>>v;
        memset(d,0,sizeof(d));
        memset(c,0,sizeof(c));
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        ans=0,ans2=0;
        for(int i=1;i<=n;i++)
        {
            cin>>d[i]>>c[i]>>a[i];
            maxa=max(a[i],maxa);
            mina=min(a[i],mina);
        }
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
        }
        sort(p+1,p+m+1);
        if(maxa==0&&mina==0)
        {
            ans2=m;
            for(int i=1;i<=n;i++)
            {
                if(c[i]>v&&p[m]>=d[i])
                {
                    ans++;
                    if(ans!=0)
                    {
                        ans2=m-1;
                    }
                    else
                    {
                        ans2=m;
                    }
                }
            }
            cout<<ans<<" "<<ans2<<endl;
        }
        else if(mina>0)
        {
            for(int i=1;i<=n;i++)
            {
                if(p[m]>=d[i])
                {
                    long long x=(c[i]*c[i])+2*a[i]*(p[m]-d[i]);
                    if(x>(v*v))
                    {
                        ans++;
                    }
                }
            }
            if(ans!=0)
            {
                ans2=m-1;
            }
            else
            {
                ans2=m;
            }
            cout<<ans<<" "<<ans2<<endl;
        }
        else if(n<=20&&m<=20)
        {
            for(int i=1;i<=n;i++)
            {
                if(a[i]>0&&p[m]>=d[i])
                {
                    int x=c[i]+2*a[i]*(p[m]-d[i]);
                    if(x>(v*v))
                    {
                        ans++;
                        b[m]=1;
                    }
                }
                else if(a[i]<0)
                {

                }
                else
                {

                }
            }
        }
    }
    return 0;
}
